package uk.ac.cam.echo.reader;

import java.io.*;

/**
 * @author Andrius Dagys
 */

public class Configuration {

	private String server;
	private int port;
	private String readerPort;
	private String uiPort;
	private boolean checkInMode;
	private int attractionId;
	private String attractionName;
	
	/**
	 * Reads application settings from the given configuration file
	 * @param configFile 
	 * The format of the configuration file:
	 * Server
	 * Port
	 * Scanner port name
	 * UI port name
	 * Attraction id
	 * Attraction name
	 * true/false - specifies whether to run in CheckIn mode.
	 * 
	 */
	Configuration(String configFile) {

		try {
			// Open the file that is the first
			// command line parameter
			FileInputStream fstream = new FileInputStream(configFile);
			// Get the object of DataInputStream
			DataInputStream in = new DataInputStream(fstream);
			BufferedReader br = new BufferedReader(new InputStreamReader(in));
			
			this.server = (br.readLine());
			this.port = (Integer.parseInt(br.readLine()));
			this.readerPort = (br.readLine());
			this.uiPort = (br.readLine());
			this.attractionId = Integer.parseInt(br.readLine());
			this.attractionName = br.readLine();
			this.checkInMode = (Boolean.parseBoolean(br.readLine()));
			
			in.close();
		} catch (Exception e) {// Catch exception if any
			System.err.println("Error: " + e.getMessage());
		}
	}

	public boolean isCheckInMode() {
		return checkInMode;
	}
	public String getServer() {
		return server;
	}
	public int getPort() {
		return port;
	}
	public String getReaderPort() {
		return readerPort;
	}
	public String getUiPort() {
		return uiPort;
	}
	public int getAttractionId() {
		return attractionId;
	}

	public String getAttractionName() {
		return attractionName;
	}
}
